using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class FearDarkBuff : BuffBase
{
    protected override void OnEnable()
    {
        if (TryGetComponent<AbstractCharacter>(out _))
        {
            character = this.transform.GetComponent<AbstractCharacter>();
            character.AddBuffToList(this);
            BuffItem = Instantiate(Resources.Load("Buff/FearDarkBuff")) as GameObject;
            BuffItem.transform.SetParent(RoleManager.Instance.buffs);
        }
        isCountDown = false;
        FightManager.Instance.OnBattleWin += RemoveBuff;
    }

    public void RemoveBuff()
    {
        if (character != null)
        {
            character.RemoveBuffFromList(this);
            FightManager.Instance.OnBattleWin -= RemoveBuff;
            Destroy(transform.GetComponent<FearDarkBuff>());
            Destroy(BuffItem);
        }
    }
}
